package demo.icanci.pattern.factory.method;

import demo.icanci.pattern.factory.entity.Mouse;

/**
 * Factory Mouse Demo
 * 工厂方法模式
 * 优点：
 * - 遵循开闭原则
 * - 对客户端隐藏创建细节
 * - 符合单一职责原则
 * 缺点：
 * - 添加子类的时候，会非常多
 * - 只支持同一类产品的创建
 *
 * @author icanci
 * @date Created in 2021/02/04 23:06
 * @version 1.0
 */
public class FactoryMethodDemo {
    public static void main(String[] args) {
        DellMouseFactory dellMouseFactory = new DellMouseFactory();
        Mouse dellMouse = dellMouseFactory.createMouse();
        dellMouse.sayHi();
        HpMouseFactory hpMouseFactory = new HpMouseFactory();
        Mouse hpMouse = hpMouseFactory.createMouse();
        hpMouse.sayHi();
    }
}
